[#ftl]
[#include "commonDef.ftl" /]
${pack_own}

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

${base_pack}.common.annotation.Log;
${base_pack}.common.utils.StringUtils;
${base_pack}.common.core.domain.R;
${base_pack}.common.core.controller.BaseController;
${base_pack}.common.core.page.TableDataInfo;
${base_pack}.common.enums.BusinessType;
${pack_service}
[#-- 方法对象引入 --]
${import_method_class2}
${import_class}

/**
 * ${module_title+'-'+data_main.moduleKeyName}
 * @author ${author_str!"zhouliang"}
 * @date ${date_str}
 */
@RestController
@RequestMapping("${ControllerUrl(data_main)}")
public class ${name_own} extends BaseController {
    @Autowired
    private ${name_service} ${lname_service};
[#if resource_class??]
    ${resource_class}[#-- 载入类 --]
[/#if]
 
[#if data_method??]
[#list data_method as mdx]
[#if mdx.needFlag == '1']
    /**
     * ${ControllerMethodTitle(data_main,mdx)}
     */
    @PreAuthorize("@ss.hasPermi('${PermissionFunc(data_main,mdx.methodCode1)}')")
[#if checkTypeFunc(mdx.methodOprType,["getdetail","getlist"]) ]
    @${mdx.fieldEx['requestType']!"Get"}Mapping("${mdx.methodUrl}")
    public R<${mdx.tags['name_res']}> ${ControllerMethodName(data_main,mdx)}(@Validated ${mdx.tags['name_req']} reqData) throws Exception{
        ${mdx.tags['name_res']} data = ${lname_service}.get${ServiceMethodName(data_main,mdx)}(reqData);
        return R.ok(data);
    }
[#elseif checkTypeFunc(mdx.methodOprType,["getpage"]) ]
    @${mdx.fieldEx['requestType']!"Get"}Mapping("${mdx.methodUrl}")
    public TableDataInfo<${mdx.tags['name_res']}> ${ControllerMethodName(data_main,mdx)}(@Validated ${mdx.tags['name_req']} reqData) throws Exception{
        [#assign eList = mdx.orderEntitys["req"]![]/]
        [#list eList as eVO]
        [#if eVO.conditionSymbol=='lk' ]
        if(StringUtils.isNotBlank(${'reqData.get'+eVO.fieldJavaCode?cap_first+'()'})){
           reqData.set${eVO.fieldJavaCode?cap_first}("%"+${'reqData.get'+eVO.fieldJavaCode?cap_first+'()'}+"%");
        }
        [/#if]
        [/#list]
        
        return ${lname_service}.get${ServiceMethodName(data_main,mdx)}(reqData);
    }
[#elseif checkTypeFunc(mdx.methodOprType,["doedit","doadd","dodelete"]) ]
    @Log(title = "${ControllerMethodTitle(data_main,mdx)}", businessType = BusinessType.${mdx.fieldEx['businessType']!"UPDATE"})
    @${mdx.fieldEx['requestType']!"Post"}Mapping("${mdx.methodUrl}")
    public R<${mdx.tags['name_res']}> ${ControllerMethodName(data_main,mdx)}(@Validated @RequestBody ${mdx.tags['name_req']} reqData) throws Exception{
        ${mdx.tags['name_res']} data = ${lname_service}.do${ServiceMethodName(data_main,mdx)}(reqData);
        return R.ok(data);
    }
[#elseif checkTypeFunc(mdx.methodOprType,["doexport"]) ]
[#elseif checkTypeFunc(mdx.methodOprType,["doimport"]) ]
[#else]
    @${mdx.fieldEx['requestType']!"Post"}Mapping("${mdx.methodUrl}")
    public R<${mdx.tags['name_res']}> ${ControllerMethodName(data_main,mdx)}(@Validated ${mdx.tags['name_req']} reqData) throws Exception{
        ${mdx.tags['name_res']} data = ${lname_service}.do${ServiceMethodName(data_main,mdx)}(reqData);
        return R.ok(data);
    }
[/#if]

[/#if]
[/#list]
[/#if]
}
